﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class LoopProList : MonoBehaviour
{
    public GameObject[] mGameObjects;
    public int[] curData = null;

    private void Awake()
    {
        List<GameObject> lis = new List<GameObject>();

        for (int i = 0; i < transform.childCount; i++)
        {
            lis.Add(transform.GetChild(i).gameObject);
        }

        childs = new GameObject[transform.childCount];

        for (int i = 0; i < transform.childCount; i++)
        {
            childs[i] = transform.GetChild(i).gameObject;
        }

        mGameObjects = lis.ToArray();
    }

    public GameObject[] childs;

    public void SetData(int[] data)
    {
        curData = data;
    }

    public void OnInit()
    {
        for (int i = 0; i < childs.Length; i++)
        {
            if (i >= curData.Length)
            {
                childs[i].SetActive(false);
            }
            else
            {
                childs[i].transform.GetChild(0).GetComponent<Text>().text = curData[i].ToString();
            }
        }
    }
}